<template>
  <div style="flex:1;" class="flex">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
        <div novalidate class="form-inline" partial>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_userinfo_id" placeholder='用户编号'
            condition="e.f_userinfo_id = '{}'" v-next-el='username'
            :size="model.f_userinfo_id ? model.f_userinfo_id.length: 4">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_user_name" placeholder='用户姓名'
            condition="e.f_user_name = '{}'" v-next-el='userid' v-el:username
            :size="model.f_user_name ? model.f_user_name.length * 2 : 4">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_user_id" placeholder='表编号'
            condition="e.f_user_id = '{}'" v-next-el='meterbrand' v-el:userid
            :size="model.f_user_id ? model.f_user_id.length : 3">
          </div>
          <div class="form-group">
            <v-select id="f_meter_brand"
              v-model="model.f_meter_brand"
              placeholder='气表品牌'
              :value.sync="model.f_meter_brand"
              :options='$parent.$parent.brand'
              close-on-select >
            </v-select>
          </div>
          <!-- <div class="form-group">

              <input  type="text" class="form-control" v-model="model.f_meternumber" placeholder='表品牌'
              condition="e.f_meter_brand = '{}'" v-next-el='area' v-el:meterbrand
              :size="model.f_meter_brand ? model.f_meter_brand.length * 2 : 2">
          </div> -->
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_area" placeholder='区域'
            condition="e.f_area like '%{}%'" v-el:xq v-next-el='address' v-el:area
            :size="model.f_area ? model.f_area.length * 2 : 2">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_address" placeholder='地址'
            condition="e.f_address like '%{}%'" v-next-el='float' v-el:address
            :size="model.f_address ? model.f_address.length * 2 : 2">
          </div>
          <div class="form-group">
            <v-select id="f_user_type"
              v-model="model.f_user_type"
              placeholder='用户类型'
              :value.sync="model.f_user_type"
              :options='$parent.$parent.usertypes'
              condition="e.f_user_type = '{}'"
              close-on-select >
            </v-select>
          </div>
          <!-- <div class="form-group">
            <input  type="number" class="form-control" v-model="model.f_float" placeholder='0'
            v-next-el='cx' v-el:float
            :size="model.f_float ? model.f_float.length : 2">
          </div> -->
          <div class="form-group">
            <button class="btn btn-success width-80" @click="search()" v-el:cx>查询</button>
          </div>
          <div class="form-group">
            <export-excel :data="{condition: condition}"  bean="异常抄表导出" sqlurl="rs/logic/exportfile"></export-excel>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
             <th>序号</th>
             <th>用户编号</th>
             <th>用户姓名</th>
             <th>用户类型</th>
             <th>区域</th>
             <th>地址</th>
             <th>表编号</th>
             <th>表品牌</th>
             <th>应交气量</th>
             <th>同期使用气量</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{$index+1}}</td>
          <td style="text-align:center">{{row.f_userinfo_id}}</td>
          <td style="text-align:center">{{row.f_user_name}}</td>
          <td style="text-align:center">{{row.f_user_type}}</td>
          <td style="text-align:center">{{row.f_area}}</td>
          <td style="text-align:center">{{row.f_address}}</td>
          <td style="text-align:center">{{row.f_user_id}}</td>
          <td style="text-align:center">{{row.f_meter_brand}}</td>
          <td style="text-align:center">{{row.oughtamount}}</td>
          <td style="text-align:center">{{row.mean}}</td>
        </template>
      </data-grid>
  </criteria-paged>
</template>

<script>
/**
*用户档案查询列表以及添加操作组件
*/
import { PagedList } from 'vue-client'
import AppData from '../../../../stores/AppData'

export default {
  title: '异常抄表查询',
  data () {
    return {
      model: new PagedList('rs/sql/abnormalHandPlan', 50),
      rows: null
    }
  },
  props: {
    row: {}
  },
  ready () {
    this.search()
  },
  methods: {
    selfSearch (args) {
      if (args.model.f_meter_brand.length > 0) {
        if (args.model.f_meter_brand[0].f_meter_brand) {
          args.condition = `${args.condition} and e.f_meter_brand = '${args.model.f_meter_brand[0].f_meter_brand}'`
        }
      }
      this.model.search(args.condition, args.model)
    },
    search () {
      this.$refs.paged.$refs.cri.search()
    }
  },
  computed: {
    usertypes () {
      return [{label: '全部', value: ''}, ...AppData.getParam('用户类型')]
    },
    brand () {
      return [{label: '全部', value: {gasmodel: [{f_meter_style: ''}]}}, ...AppData.getGasbrand()]
    }
  }
}
</script>
<style media="screen">
  .divtext {
    min-width: 50px;
    max-width: 200px;
    border: 1px solid green;
    display: inline-block;
  }
</style>
